import { BASE_URL, TIME_OUT } from "./config";
import HYRequest from "./request";

const hyRequest = new HYRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
});

export const hyRequest2 = new HYRequest({
  baseURL: "http://codercba.com:1888/airbnb/api",
  timeout: 8000,
  interceptors: {
    requestSuccessFn: (config) => {
      console.log("API请求成功的拦截");
      return config;
    },
    requestFailureFn(error) {
      console.log("API请求失败的拦截");
      return Promise.reject(error);
    },
    responseSuccessFn(res) {
      console.log("API响应成功的拦截");
      return res;
    },
    responseFailureFn(error) {
      console.log("API响应失败的拦截");
      return Promise.reject(error);
    },
  },
});

export default hyRequest;
